import 'package:flutter/material.dart';
import 'package:tk_flutter/utils/MyBehavior.dart';
import 'package:tk_flutter/score/ScoresWidget.dart';
import 'score/model/ScoresModel.dart';
import 'score/GradeWidget.dart';
import 'score/model/GradeModel.dart';

void main() => runApp(Main());

/*
 * @auther YuanShuai
 * @created at 2019/2/19 15:34
 * @desc 得分排名
 */
class Main extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: Home(),
      theme: new ThemeData(primaryColor: Colors.white),
    );
  }
}

class Home extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _HomeState();
}

class _HomeState extends State<Home> {
  AppBar appBar = AppBar(
    elevation: 0.5,
    leading: IconButton(
      icon: Icon(
        Icons.arrow_back,
        color: Colors.black,
      ),
    ),
    actions: <Widget>[
      IconButton(
        icon: Icon(
          Icons.share,
          color: Colors.black,
        ),
      ),
    ],
    title: Text(
      '考试报告',
      style: TextStyle(color: Colors.black),
    ),
    centerTitle: true,
  );

  @override
  Widget build(BuildContext context) {


    return Scaffold(
        backgroundColor: Colors.white,
        appBar: appBar,
        body: ScrollConfiguration(
          behavior: new MyBehavior(),
          child:
          new ListView(
            children: <Widget>[
              ScoreWidget(_scoresData()),
              GradeWidget(context,_gradesData())
            ],
          ),
        ));
  }
}

Scores _scoresData(){
  return Scores(
      submitTime: "2017.06.16 00:00:00",
      score: '80.0',
      examTime:'30',
    highScore:'130',
    ranking:'88',
    average: '88',
  );
}


List<Grade> _gradesData() {
  List<Grade> items = [];
  items.add(Grade(title: '单选题',
      items: [GradeItem(isRight: true), GradeItem(isRight: true), GradeItem(isRight: true), GradeItem(isRight: false)
      ]));
  items.add(Grade(title: '多选题',
      items: [GradeItem(isRight: true), GradeItem(isRight: true), GradeItem(isRight: true), GradeItem(isRight: false),GradeItem(isRight: true), GradeItem(isRight: true), GradeItem(isRight: true),
      ]));
  items.add(Grade(title: '判断题',
      items: [GradeItem(isRight: true), GradeItem(isRight: true), GradeItem(isRight: true), GradeItem(isRight: true)
      ]));
  return items;
}
